﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TestRtf : MonoBehaviour
{
    // Start is called before the first frame update

    void Start()
    {
        var rtf = GetComponent<RectTransform>();

        Vector3 localPos = rtf.localPosition;
        Debug.Log($"localPosition: {localPos.ToStr()}");
        
        Vector2 pos = rtf.anchoredPosition;
        Debug.Log($"anchoredPosition: {pos.ToStr()}");

        Vector2 anchorMin = rtf.anchorMin;
        Debug.Log($"anchorMin: {anchorMin.ToStr()}");
        Vector2 anchorMax = rtf.anchorMax;
        Debug.Log($"anchorMax: {anchorMax.ToStr()}");

        Vector2 offsetMin = rtf.offsetMin;
        Debug.Log($"offsetMin: {offsetMin.ToStr()}");
        Vector2 offsetMax = rtf.offsetMax;
        Debug.Log($"offsetMax: {offsetMax.ToStr()}");

        Vector2 pivot = rtf.pivot;

        Vector2 sizeDelta = rtf.sizeDelta;
        Debug.Log($"sizeDelta: {sizeDelta.ToStr()}");

        Rect rect = rtf.rect;
        Debug.Log($"rect: {rect.ToStr()}, center:{rect.center.ToStr()}");

        var parentRtf = (RectTransform)this.transform.parent;
        Rect myRect = rtf.rect;
        Vector2 mySize = myRect.size;
        Vector2 parentSize = parentRtf.rect.size;
        Vector2 myLPos = rtf.localPosition;
        Vector2 ltVec2 = myLPos + myRect.min + parentSize * parentRtf.pivot;
        Debug.Log($"ltVec2: {ltVec2.ToStr()}");
        
        ltVec2 += new Vector2(0, mySize.y);
        Debug.Log($"ltVec2: {ltVec2.ToStr()}");
        
        ltVec2 += new Vector2(0, -parentSize.y);
        Debug.Log($"ltVec2: {ltVec2.ToStr()}");
    }


    // Update is called once per frame
    void Update()
    {
        
    }
    
}
